package com.ctsi.system.strategy.impl;

import com.ctsi.system.entity.Org;
import com.ctsi.system.service.IOrgService;
import com.ctsi.system.strategy.IDataScope;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 所有数据权限
 *
 * @version 1.0
 * @author: wang xiao xiang
 * @date: 2021/8/9 16:18
 */
@Component(IDataScope.ALL)
@RequiredArgsConstructor
public class AllDataScope implements IDataScope {

    private final IOrgService orgService;

    @Override
    public List<Long> getOrgIds(List<Long> orgIds, Long userId) {
        // 根据所有组织机构ID列表
        List<Org> list = orgService.lambdaQuery().select(Org::getId).list();
        // 拼装数据格式并返回
        return list.stream().map(Org::getId).collect(Collectors.toList());
    }
}
